package mspbots.cw.business.core.boards;

import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import reactor.core.publisher.Mono;

/**
 * @author Jay.Yang
 */
public interface BoardAssociationsRepository extends R2dbcRepository<BoardAssociations, Long> {

    /**
     * find entity other id and tenant id
     *
     * @param cwId       cwId
     * @param tenantCode tenantCode
     * @return account entity
     */
    Mono<BoardAssociations> findByCwIdAndTenantCode(Long cwId, Long tenantCode);

    @Query("select count(*) from connectwise_board_associations where tenant_code=:tenantCode and board_id=:boardId and type_id=:typeId and sub_type_id is not null")
    Mono<Integer> findByBoardIdAndTypeIdAndTenantCode(Long boardId, Long typeId, Long tenantCode);
}
